package com.hobson.design.factory.builder;

import java.util.ArrayList;
import java.util.List;

/**
 * 订单客户端
 *
 * @author: haibin.tang
 * @date: 2020/8/6
 */
public class OrderClient {
    public static void main(String[] args) {
        CreateOrderRequest request = new CreateOrderRequest();
        request.setCouponId("C" + System.currentTimeMillis());
        List<CreateOrderRequest.Item> items = new ArrayList<>();
        for (int index = 1; index < 10; ++index) {
            CreateOrderRequest.Item item = new CreateOrderRequest.Item();
            item.setProductId("P" + System.currentTimeMillis());
            item.setQuantity(Math.round(3));
            items.add(item);
        }
        request.setProducts(items);
        new DefaultOrderBuilder(request).check().stock().coupon().countingPrice().build();
        System.out.println("\n");
        //不参与库存锁定和优惠券抵扣
        new DefaultOrderBuilder(request).check().countingPrice().build();
    }
}
